
var IAdministrativeDivisions=Server.create("com.zhao.tongcheng.intf.IAdministrativeDivisions");
function getCityListByProvinceId()
{
		var provinceId=$("#provinceId").val();
		var json=IAdministrativeDivisions.call("getCityListByProvinceId",provinceId);		
		json=$.xml2json(json);
		return json;
		
}
function getProvinceList()
{
		
		var json=IAdministrativeDivisions.call("getProvinceList");
		json=$.xml2json(json);
		
		var ProvinceList = json.body.provinceList.province;
		 
		
		//alert(object2String(json.body.provinceList.province));
		var table="";
		for(i=0;i<ProvinceList.length;i++)
		{
			//alert(ProvinceList[i]);
			table=table+"<option>"+ProvinceList[i].name+"</option>";
		}
		//alert(object2String(json));
		$("#ProvinceList").html(table);
		
		return json;
}
function object2String(obj) {

    var val, output = "";

    if (obj) {   

        output += "{";

        for (var i in obj) {

            val = obj[i];

            switch (typeof val) {

                case ("object"):

                    if (val[0]) {

                        output += i + ":" + array2String(val) + ",";

                    } else {

                        output += i + ":" + object2String(val) + ",";

                    }

                    break;

                case ("string"):

                    output += i + ":'" + encodeURI(val) + "',";

                    break;

                default:

                    output += i + ":" + val + ",";



            }

        }

        output = output.substring(0, output.length-1) + "}";

    }

    return output;

}

function array2String(array) {

    var output = "";

    if (array) {

        output += "[";

        for (var i in array) {

            val = array[i];

            switch (typeof val) {

                case ("object"):

                    if (val[0]) {

                        output += array2String(val) + ",";

                    } else {

                        output += object2String(val) + ",";

                    }

                    break;

                case ("string"):

                    output += "'" + encodeURI(val) + "',";

                    break;

                default:

                    output += val + ",";

            }

        }

        output = output.substring(0, output.length-1) + "]";

    }

    return output;

}